﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Linq;

using System.Text;
using OgilvyOne.Ext.Weibo.Common;
using OgilvyOne.Ext.Weibo.Configuration;
using OgilvyOne.Ext.Weibo.Lib;

using ECCIT;
using ECCIT.Data;
using OgilvyOne.Model;
using OgilvyOne.BLL;
using OgilvyOne.Ext.Weibo.Model;
using System.Collections.ObjectModel;

using System.Configuration;

public partial class SaveShare : System.Web.UI.Page
{
    StringBuilder sb = new StringBuilder();
    protected void Page_Load(object sender, EventArgs e)
    {
        string guid = Request.QueryString["guid"];
        string lang = Request.QueryString["lang"];
        Response.ContentType = "text/xml";
        Response.ContentEncoding = Encoding.UTF8;
        sb.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
        sb.AppendLine(@"<root>");
        if (Session["weibo"] == null)
        {
            sb.AppendLine(string.Format("<result>{0}</result>", "101"));
        }
        else
        {
            if (!string.IsNullOrEmpty(guid))
            {
                string language = lang == "cn" ? "cn" : "en";
                StringBuilder strSb = new StringBuilder();
                object obj = OgilvyOne.BLL.DataCache.GetCache(guid);
                 if (obj!=null)
                {
                    strSb.Append(obj.ToString());
                    int flag = SaveXml(strSb, guid,lang);
                    if (flag > 0)
                    {
                        sb.AppendLine(string.Format("<result>{0}</result>", "100"));
                    }
                }
                else
                {
                    sb.AppendLine(string.Format("<result>{0}</result>", "103"));
                }
            }
            else
            {
                sb.AppendLine(string.Format("<result>{0}</result>", "102"));
            }
        }
        sb.AppendLine(@"</root>");
        Response.Write(sb);

    }
    public int SaveXml(StringBuilder sb, string guid,string lang)
    {
        return new UserBLL().Save(sb, guid, lang);
    }
}